<template>
  <div class='container'>
    <el-dialog
      title="试题审核"
      :visible.sync="dialogVisible"
      width="30%">
      <el-form :model="formBase" :rules="rules" ref="ruleForm" class="demo-ruleForm">
        <el-form-item >
          <el-radio v-model="formBase.chkState" :label="1">通过</el-radio>
          <el-radio v-model="formBase.chkState" :label="2">拒绝</el-radio>
        </el-form-item>
        <el-form-item prop="chkRemarks">
          <el-input
            type="textarea"
            :rows="2"
            placeholder="请输入内容"
            v-model="formBase.chkRemarks">
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button >{{$t('table.cancel')}}</el-button>
        <el-button type="primary" @click="confirm">{{$t('table.confirm')}}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions.js'
export default {
  data () {
    return {
      dialogVisible: false,
      rules: {
        chkRemarks: [{ required: true, message: '请输入审核评价', trigger: 'blur' }]
      },
      formBase: {
        id: null,
        chkState: 1,
        chkRemarks: null
      }
    }
  },
  methods: {
    // 审核
    openDialog (id) {
      this.dialogVisible = true
      this.formBase = {
        id: id,
        chkState: 1,
        chkRemarks: null
      }
    },
    async confirm () {
      try {
        await this.$refs.ruleForm.validate()
        await choiceCheck(this.formBase)
        this.$message.success('审核完成')
        this.$emit('finish')
        this.closeDialog()
      } catch (error) {
        console.log(error)
      }
    },
    closeDialog () {
      this.dialogVisible = false
    }
  }
}
</script>

<style scoped lang='less'>
</style>
